Page({
  /**
   * 页面的初始数据
   */
  data: {
    sourceList: [],
    searchvalue: "",
    date: '',
    datePickerValue: ['', '', ''],
    datePickerIsShow: false

  },

  /**
   * 生命周期函数--监听页面加载this
   */
  onLoad: function () {
  },

  onShow: function () {
    console.log(" datalist", this.getmineclassesdata(null, null))
    if (typeof this.getTabBar === 'function' &&
        this.getTabBar()) {
        this.getTabBar().setData({
          selected: 0
        })
  }
  },


  // 拉取信息
  getmineclassesdata: function (date, pagenum) {

    var nowdate = new Date();
    var _this = this;
    if (date != null) {
      var date = date
      console.log(date)

    } else {


      var tMonth = nowdate.getMonth();

      var m = tMonth + 1;
      if (m.toString().length == 1) {
        m = "0" + m;
      }

      var date = nowdate.getFullYear() + "-" + m + "-" + nowdate.getDate()
      console.log(date)
    }

    var ip = "http://43.254.44.222:9002/api/work/workLimitList?nowTime="
    var query = "&query=&page="
    if (pagenum == null) {
      var page = 1

    } else {
      var page = pagenum
    }

    var limit = "&limit=10"
    var url = ip + date + query + page + limit
    console.log(url)








    wx.request({
      url: url, //仅为示例，并非真实的接口地址
      data: {
        //  name: this.data.searchvalue ,
      },
      method: "POST",
      header: {
        //application/json
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
        console.log(res.data.data.pageRecode)

        console.log("111===", _this.data.sourceList)
        _this.setData({
          sourceList: res.data.data.pageRecode

        })





      }
    })
    this.mineclassesdata = [

      {
        address: null,
        avatar: null,
        classTypeDate: "2021-04-24",
        id: 11996,
        identity: 20,
        phone: "17629237911",
        queue: "视频云队列",
        sex: "男",
        uid: 8,
        uname: "李毅",
        username: "李毅",
        utime: "09:00--22:00",
        utype: "D3",
        utypeName: "终端队列,云通信队列",
      }

    ];

    _this.setData({
      sourceList: this.mineclassesdata
    })
  },
  searchValueInput: function (e) {
    var value = e.detail.value;
    var _this = this;

    _this.setData({
      searchvalue: value,
    });

  },
  // 查询
  search: function () {

    console.log(this.data.searchvalue)
    var _this = this;
    var search = [];
    let l = -1;


    for (let i = 0; i < _this.data.sourceList.length; i++) {


      if (_this.data.sourceList[i].username == this.data.searchvalue || _this.data.sourceList[i].queue == this.data.searchvalue) {

        l++;

        search[l] = _this.data.sourceList[i]
      } else {
        console.log(l)


      }
      console.log(_this.data.date)




    }

    if (search.length > 0) {

      _this.setData({
        sourceList: search

      })
    } else {
      this.getmineclassesdata(null, null);

    }





  },

  //日期处理
  showDatePicker: function (e) {
    // this.data.datePicker.show(this);
    this.setData({
      datePickerIsShow: true,
    });
  },
  //日期格式修改
  datePickerOnSureClick: function (e) {
    console.log('datePickerOnSureClick');
    console.log(e);
    this.setData({
      date: `${e.detail.value[0]}-${e.detail.value[1]}-${e.detail.value[2]}`,
      datePickerValue: e.detail.value,
      datePickerIsShow: false,
    });
    var datalist = []



    datalist = this.getmineclassesdata(this.data.date, null)
    console.log(" datalist==", datalist)




  },

  datePickerOnCancelClick: function (event) {
    console.log('datePickerOnCancelClick');
    console.log(event);
    this.setData({
      datePickerIsShow: false,
    });
  },




})